package example;

import java.util.Timer;
import java.util.TimerTask;

/**
 * @author hyaninth
 * @date 2023/5/9
 */
public class Example12 {
    public static void main(String[] args) {
        // 标准库的定时器
        Timer timer = new Timer();
        // 1.任务 2.时间
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("5s!");
            }
        },5000);
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("3s!");
            }
        },3000);
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("4s!");
            }
        },4000);
        System.out.println("计时开始!");
    }
}
